Repository navigation
fix(metadata-protocol): a package's rollback, revert or package rollback of its own permission set restores beside another namespace's shipped set - #34550
Conversation
… set beside another namespace's shipped set Claude-Session: https://claude.ai/code/session_01ADHkmPhrvD6HH5p4xPZ2jX Co-authored-by: Claude <noreply@anthropic.com>
…permission set as a top-level describe; add its changeset Claude-Session: https://claude.ai/code/session_01ADHkmPhrvD6HH5p4xPZ2jX Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check3 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 010a8a3f2813cdf4cea23b15bbbd8b1206680fe3 && git checkout 010a8a3f2813cdf4cea23b15bbbd8b1206680fe3
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 631d77f3021ca00e36a3cb51e19a4d8ee361fdc6 bf5dccdba278ebed573762619fb96bf7d9bdcde8 && git checkout -B drift-repro 631d77f3021ca00e36a3cb51e19a4d8ee361fdc6 && git merge --no-ff bf5dccdba278ebed573762619fb96bf7d9bdcde8
node scripts/docs-audit/affected-docs.mjs --json 631d77f3021ca00e36a3cb51e19a4d8ee361fdc6 |
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Final head for review: |
|
repo:objectstack#2 · os-steve · session_01ADHkmPZf3MhxKeGaxV4P3W 席位核对L1 first review · ACCEPT · head Checklist (read on GitHub at this head, not from the report)
Owed after this
|
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Contract reviewServed-tier: The face is the declaration only: ① Derived judgments
② Semver levelClause-②: yes (widening) A rollback, a commit revert or a package rollback refused 403 ③ Boundary flags
Implemented-by: VERDICT: PASS |
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Landing
State: ready, auto-merge armed. |
Requested by Steve · project thread
Fixes #34401
Clause-②: yes (widening) — a rollback, a commit revert or a package rollback of a package's own permission set N, refused 403
NOT_OVERRIDABLE("provided by a managed package and is sealed") while a package of another namespace ships N, now restores; a delete of that set answers "Deleted permission 'N' (package=P) — it no longer exists." in place of "Customization overlay deleted (package=P) — permission/N reset to artifact default.", withreset: trueas before; nothing the doors accepted is refusedMetadata-protocol: none
维护者速读
isOwnPermissionSetWrite,凡是覆盖 crm 所发布 N 的恢复(不绑包、绑 crm、绑 crm 的定制配对包、绑 crm 或 fin 同命名空间的包)仍按原来的错误码拒绝。回滚即 revert 本 PR,无数据迁移。packages/metadata-protocol/src/protocol-class-head.ts(restoreWriteFor一行收窄,回滚与提交回退共用),packages/metadata-protocol/src/protocol-diff-delete-load.ts(删除回执的同一判定)。pnpm --filter @objectstack/plugin-security exec vitest run src/packaged-permission-set-lock-gate.test.ts,预期 71 个全部通过,其中[#34401]一组覆盖两种注册顺序下的恢复、删除回执和全部拒绝对照。What changes
A permission set is
(package, name)(ADR-0150 D2/D9). #34359 made the save door, the draft publish and the publish undo judge a write of a package's own setNby the package it is addressed to (isOwnPermissionSetWrite,protocol-packaged-base-refusal.ts). The per-item rollback and a commit revert's restore limb still handedrestoreWriteForthe name-wideisArtifactBacked, so a restore intohr's ownN, whilecrmof another namespace shipsN, was toldoverride-artifactand refused by the store's managed seal.restoreWriteFor(protocol-class-head.ts), the one derivation both restore sites share, narrows theartifactBackedit receives byisOwnPermissionSetWrite(engine, type, name, binding), wherebindingis the row the restore writes (the rollback's resolved row binding, the revert's commit package). A restore into a package's own set is a runtime-only write, as that package's save is. Every other restore keeps the intent and the pair handling it had. One place covers all three doors:POST /api/v1/meta/:type/:name/rollback,POST /packages/:id/commits/:commitId/revert, andPOST /packages/:id/rollback, which reverts commit by commit.deleteMetaItem(protocol-diff-delete-load.ts): the two repository-path receipts that claim a code-shipped item sits under the deleted address (the success receipt and the "no row" receipt) read the same verdict at the resolved address. A delete ofhr's ownNanswers "Deleted permission 'N' (package=hr) — it no longer exists."; a delete naminghrwhenhrholds noNanswers "No permission 'N' found — nothing to delete.". The delete's write intent is unchanged (the store already admits it; see Acceptance notes).N(crm shipsN)hr's ownNto v1NOT_OVERRIDABLE, v2 kepthr's grant confers v1hr's commit that editedNNinfailed[],NOT_OVERRIDABLEfailed: []rollbackToPackageCommittohr's earlier commitfailed[]crmANDfinshippingNhr's ownNreset: true, "Customization overlay deleted (package=hr) — permission/N reset to artifact default."reset: true, "Deleted permission 'N' (package=hr) — it no longer exists."hr, nohrrowNOT_OVERRIDABLERESOURCE_CONFLICTNAMESPACE_CONFLICTNbound to crm / crm's pairfailed[]NOT_OVERRIDABLENbound to no package / a co-ownerfailed[]NAMESPACE_CONFLICTNreset: true, "… reset to artifact default."Tests
packages/plugins/plugin-security/src/packaged-permission-set-lock-gate.test.ts, the #34226 pin file:[#34401] restoring or deleting a package's own set N beside another namespace's shipped N, every case in both registration orders: the rollback, the commit revert and the package rollback restore v1 (andhr's grant confers it);crmandfinboth shipping still restores; ten CONTROL cases (5 rollback, 5 revert) assert thecodeandstatusmain answered, measured before the fix, and that the active row is untouched; the two delete receipts; a CONTROL that the pair's customization delete still reads as a reset.N,composition,confers) moved from inside that describe to module scope, unchanged, so both describes share it.git diff -wshows the move as whitespace.sys_metadatais keyed by its own id, so a second package commit no longer overwrites the first, and the history rows are exposed for the CONTROL rebind. NofindOne/update/deletedouble was added (check:engine-double-contractcounts unchanged).Acceptance notes
reset: falseon the delete ofhr's ownN.DeleteMetaItemResponseSchemadefinesreset === trueas "a row was deleted" andfalseas "nothing was removed", soresetstaystrue(a row was deleted) and only the receipt text changes. Amended claim 6932622107 records this.revertCommit's removal limb (isArtifactBackedalone). Both hand the storeoverride-artifactforhr's ownN, andassertDeleteAllowedadmits it for asupportsOverlaytype, so nothing is refused and the change would not be observable. The card names the removal limb as not refused.RESOURCE_CONFLICT, and the co-owner CONTROLs answer 422NAMESPACE_CONFLICT. Those refusals are judged ahead of the restore, on main as on this branch.Verification
FROM on main source, ablations, suites and gates
bdd51769): 22 failed / 10 passed. Rollback 403NOT_OVERRIDABLE; revertfailed[]NOT_OVERRIDABLE; package rollback failed; delete receipt "reset to artifact default". The CONTROL envelopes were read from this run and pinned.pnpm --filter @objectstack/plugin-security exec vitest run src/packaged-permission-set-lock-gate.test.ts, 71 passed (71).restoreWriteFornarrowing removed,const overridesShipped = artifactBacked;): 8 failed / 63 passed. The failures are the rollback, revert, package rollback and two-shipper cases, both orders. Restored: blob == HEAD.;and was a no-op thatablation-replace.mjsrefused (replacement count did not move), so no reading. Re-run with a marker replacement: 4 failed / 67 passed, the two delete-receipt cases in both orders. Restored: blob == HEAD.@objectstack/metadata-protocolto source (vitest.config.tsalias), so no rebuild is needed between legs.origin/main, underos-verify-lock, VERDICT command-exit 0: closure build,metadata-protocoltypecheck,plugin-securitytypecheck,plugin-securitytest (274 files, 6883 passed / 45 skipped),metadata-protocoltest (346 passed / 9 skipped files, 22968 passed / 45 skipped).bf5dccdba2: 74 derived, 74 run, 0 NOT-MEASURED (dispatch-gates.mjs --ran). The first pass had 3 exit-3 prerequisites (check-plugin-teardown-shape --self-teston a shallow clone;check:dual-build-cjs-loadsandcheck:i18non an unbuilt workspace). Each re-ran to exit 0 aftergit fetch --unshallowand a fullpnpm build(VERDICT command-exit 0).